
<!--
/**************************************************
* @ providerview.jsp
*
* Copyright   2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/02/27, owen
*  1) first release
/**************************************************
-->


<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="../common.jsp"%>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<%@ include file="../../framework/head.jsp"%>
<html>
<head>
<title>供应商浏览</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<%
    ArrayList tGSCountry = (ArrayList) request.getAttribute("country");
    ArrayList tGSProvince = (ArrayList) request.getAttribute("province");
    GSProvinceBean tProvinceBean = null;
    String[][] tProvDist = null;
    HashMap tMap2 = new HashMap();
    ArrayList tGSDistinct = (ArrayList) request.getAttribute("district");
    GSDistrictBean tDistrictBean = null;
    if (tGSProvince != null) {
        for (int i = 0; i < tGSProvince.size(); i++) {
            String tProvcode = ((GSProvinceBean) tGSProvince.get(i)).getGs_province_code();
            if (tGSDistinct != null) {
                tProvDist = new String[tGSDistinct.size()][2];
                for (int j = 0; j < tGSDistinct.size(); j++) {
                    tDistrictBean = (GSDistrictBean) tGSDistinct.get(j);
                    if (tDistrictBean.getGs_province_code().equals(tProvcode)) {
                        tProvDist[j][0] = tDistrictBean.getGs_district_code();
                        tProvDist[j][1] = tDistrictBean.getGs_district_name();
                        tMap2.put(tProvcode, tProvDist);
                    }//end if
                }//end for
            }//end if
        }//end for
    }//end if	

    ResultProcess tGSProvider = (ResultProcess) request.getAttribute("provider");
    String[][] tGSCorpProperty = (String[][]) request.getAttribute("corpproperty");
    ArrayList tList = new ArrayList();
    String tReQuery = (String) request.getAttribute("requery");
    boolean flag = false;
    if (GSSystemConfigurator.getInstance().getProjectVersionType().equals("SH")) {
        flag = true;
    }
    //out.println(message);
%>
<script language="JavaScript">
	var counter;
	
    function providerImport()
    {
       window.open("/gw/jsp/providerImport.jsp");
    }
	
	function process(val){
		if(val == 'Q' || val == 'Qre'){
				  if (val == 'Qre') {
					<%
					    if(tReQuery!=null && tReQuery.equals("true")){
					        
					%>
					   
						providerviewform.action = "<%= response.encodeURL(request.getContextPath() + "/A400102.do") %>";
                        providerviewform.submit();
                        return true;
			    	<%}%>
		    	} else if (val == 'Q') {
						providerviewform.action = "<%= response.encodeURL(request.getContextPath() + "/A400102.do") %>";
                        providerviewform.submit();
                        return true;
		    	}
    	
		}
	}
	function add(){
        var result = null;	
		result = showModalDialog("<%= response.encodeURL(request.getContextPath() + "/A400103.do") %>", window,"status:no;unadorned:no;dialogWidth:900px;dialogHeight:600px;help:no;");
		if(result != null){
	       proform.gs_provider_id.value=result[0];
           proform.gs_provider_shortname.value=result[1];
           proform.gs_provider_name.value=result[2];
           proform.gs_provider_engname.value=result[3];
           proform.gs_corp_property.value=result[4];
           proform.gs_credit_level.value=result[5];
           proform.gs_corp_addr.value=result[6];
           proform.gs_corp_post.value=result[7];
           proform.gs_principal_id.value=result[8];
           proform.gs_principal_phone.value=result[9];
           proform.gs_contact_id.value=result[10];
           proform.gs_contact_phone.value=result[11];
           proform.gs_reside_country.value=result[12];
           proform.gs_reside_province.value=result[13];
           proform.gs_reside_city.value=result[14];
           proform.gs_work_trade.value=result[15];
           proform.gs_work_manufacture.value=result[16];
           proform.gs_work_scope.value=result[17];	
           proform.isAudit.value=result[18];
		   proform.action="<%= response.encodeURL(request.getContextPath() + "/A400104.do") %>";   
	       proform.submit();
		}
        return true;
      }
      
	function exportProvider(){
		providerviewform.action = "<%= response.encodeURL(request.getContextPath() + "/A400109.do") %>";
        providerviewform.submit();
        return true;
      } 
	
      function setNot() {
        var checkboxvalue = document.getElementsByName("temporary_manufacture");
        var selectnum = 0;
        for(i=0;i<checkboxvalue.length;i++){
            if(checkboxvalue[i].checked){
             selectnum++;
              
            }
        }
        if(selectnum ==0) {
            alert("请至少选择一个供应商");
            return false;
        }
        
        if(confirm("是否删除此供应商？")){
              pager.providerName.value = providerviewform.providerName.value;
              pager.countryCode.value  = providerviewform.countryCode.value;
              pager.provinceCode.value = providerviewform.provinceCode.value;
              pager.districtCode.value = providerviewform.districtCode.value;
              pager.contactid.value    = providerviewform.contactid.value;
              pager.contactphone.value = providerviewform.contactphone.value;
              pager.is_status.value = providerviewform.status.value;
            pager.action='<%= response.encodeURL(request.getContextPath() + "/A400105.do?type=0") %>';
            pager.submit();
        }
        return true;
    }
      function setOK() {
      
        var checkboxvalue = document.getElementsByName("temporary_manufacture");
        var selectnum = 0;
        for(i=0;i<checkboxvalue.length;i++){
            if(checkboxvalue[i].checked){
             selectnum++;
              
            }
        }
        if(selectnum ==0) {
            alert("请至少选择一个供应商");
            return false;
        }
        
        if(confirm("是否设置此供应商有效？")){
              pager.providerName.value = providerviewform.providerName.value;
              pager.countryCode.value  = providerviewform.countryCode.value;
              pager.provinceCode.value = providerviewform.provinceCode.value;
              pager.districtCode.value = providerviewform.districtCode.value;
              pager.contactid.value    = providerviewform.contactid.value;
              pager.contactphone.value = providerviewform.contactphone.value;
              pager.is_status.value = providerviewform.status.value;
              pager.action='<%= response.encodeURL(request.getContextPath() + "/A400105.do?type=1") %>';
              pager.submit();
        }
        return true;
    }
      
    function mod(temp){
      pager.ProviderId.value=temp;
      var id=null;
      id= pager.ProviderId.value;
      var result = null;	
	  result = showModalDialog("<%= response.encodeURL(request.getContextPath() + "/A400106.do") %>?ProviderId="+id, window,"status:no;unadorned:no;dialogWidth:900px;dialogHeight:600px;help:no;");
	  if(result != null){
	  
	       proform.gs_provider_id.value=result[0];
           proform.gs_provider_shortname.value=result[1];
           proform.gs_provider_name.value=result[2];
           proform.gs_provider_engname.value=result[3];
           proform.gs_corp_property.value=result[4];

           proform.gs_credit_level.value=result[5];
           proform.gs_corp_addr.value=result[6];
           proform.gs_corp_post.value=result[7];
           proform.gs_principal_id.value=result[8];
           proform.gs_principal_phone.value=result[9];
           proform.gs_contact_id.value=result[10];
           proform.gs_contact_phone.value=result[11];
           proform.gs_reside_country.value=result[12];
           proform.gs_reside_province.value=result[13];
           proform.gs_reside_city.value=result[14];
           proform.gs_work_trade.value=result[15];
           proform.gs_work_manufacture.value=result[16];
           proform.gs_work_scope.value=result[17];
	       proform.isAudit.value = result[18];
	       proform.action="<%= response.encodeURL(request.getContextPath() + "/A400107.do") %>";   
	       proform.submit();
	       //alert("供应商信息修改成功!");
		   //process('Q');
		}	
		return true;
    }  
    function clean(){
      providerviewform.providerName.value ="";
	  providerviewform.provinceCode.value="00";		
	  var listbox = document.getElementById("districtCode");
			listbox.length = 0;
			var option = new Option();
			option.text = "---请选择城市---";
			option.value = "00";			
			listbox.options[listbox.length] = option;	
	  providerviewform.contactid.value="";
	  providerviewform.contactphone.value="";
	  var listbox5    = providerviewform.status;
      listbox5.text  = "---全部---";
      listbox5.value  = "2";
	  
	  var listbox6    = providerviewform.isAudit;
      listbox6.text  = "---全部---";
      listbox6.value  = "";

    }
    function allCheckBox() {
        var des =document.getElementsByName('ckbox');
        for(var i=0;i<des.length;i++) {
           if(des[i].checked=document.getElementById('sel_manufacture').checked){
               des[i].checked=true;
           } else { 
               des[i].checked=false;
           }
        }
    }
    
    function del(temp){
     if (confirm("是否删除此供应商？")) {
      pager.ProviderId.value=temp;
      delform.ProviderId.value=temp;
     
      delform.providerName.value = providerviewform.providerName.value;
      delform.countryCode.value  = providerviewform.countryCode.value;
      delform.provinceCode.value = providerviewform.provinceCode.value;
      delform.districtCode.value = providerviewform.districtCode.value;
      delform.contactid.value    = providerviewform.contactid.value;
      delform.contactphone.value = providerviewform.contactphone.value;
      
      delform.action='<%= response.encodeURL(request.getContextPath() + "/A400105.do") %>';
      delform.submit();
     
     //pager.ProviderId.value=temp;
     //pager.action='<%=root%>/A400105.do';
     //pager.submit();
     return true;
   }
}
	function changedistrict(list){
		
  		var val = list;
		if(val=='00'){
			var listbox = document.getElementById("list3");
			listbox.length = 0;
			var option = new Option();
			option.text = "---请选择城市---";
			option.value = "0000";			
			listbox.options[listbox.length] = option;

		}else{
  	<%
  		if(tMap2 !=null){
	 	   	Collection tCollection = tMap2.keySet();
	        Iterator tIterator = tCollection.iterator();
  		       while(tIterator.hasNext()){
  		           String tKey = (String)tIterator.next();
  		           String[][] tDist = (String[][])tMap2.get(tKey);
  	%>
  				if(val == '<%=tKey%>'){
	  				var counter;
	  				var listbox = document.getElementById("list3");
	  				listbox.length = 0;  		  	  								
	<%					
						for(int n=0;n<tDist.length;n++){
						    String distCode = tDist[n][0];
						    String distName = tDist[n][1];
						    if(distCode != null){
	%>				
							var temp1 = '<%=distCode%>';
							var temp2 = '<%=distName%>';
							var option = new Option();
							option.value = temp1;
							option.text = temp2;
							listbox.options[listbox.length] = option;						
	<%
						    }
						}
	%>
  				}
  	<%
  		    }
  		       
  		}
  	%>
  	}	
	}
</script>
</head>
<body onload="process('Qre')">

<form name="proform" method="post"><input type="hidden"
    name="gs_provider_id"> <input type="hidden"
    name="gs_provider_shortname"> <input type="hidden"
    name="gs_provider_name"> <input type="hidden"
    name="gs_provider_engname"> <input type="hidden"
    name="gs_corp_property"> <input type="hidden"
    name="gs_credit_level"> <input type="hidden"
    name="gs_corp_addr"> <input type="hidden"
    name="gs_corp_post"> <input type="hidden"
    name="gs_principal_id"> <input type="hidden"
    name="gs_principal_phone"> <input type="hidden"
    name="gs_contact_id"> <input type="hidden"
    name="gs_contact_phone"> <input type="hidden"
    name="gs_reside_country"> <input type="hidden"
    name="gs_reside_province"> <input type="hidden"
    name="gs_reside_city"> <input type="hidden"
    name="gs_work_trade"> <input type="hidden"
    name="gs_work_manufacture"> <input type="hidden"
    name="gs_work_scope"><input type="hidden"
    name="isAudit"></form>
<p><br>
</p>
<table width="98%" border="0" cellspacing="0" cellpadding="0"
    align="center">
    <tr>
        <td height="20">
        <table width="98%" border="0" cellspacing="0" cellpadding="1">
            <tr height="20">
                <td height="20" width="1" class="mtxt_black">&nbsp;</td>
                <td height="30" width="758" class="mtxt_black">供应商管理</td>
            </tr>
        </table>
        </td>
    </tr>
    <tr>
        <td class="bg_line" height="2"></td>
    </tr>
</table>
<form name="providerviewform" method="get">

<table width="98%" border="0" cellspacing="0" cellpadding="0"
    align="center">
    <tr>
        <td>
        <table class=bg_table id=tableId cellspacing=1 cellpadding=0
            style="padding-left: 5; padding-right: 5" width=100%
            align=center border=0>
            <TR height=20>
                <!-- <TD class="bg_column" align=center>供应商编号</TD>
					<TD align=left class="bg_row_odd">
					<input type="text" name="providerId" value="<%=request.getParameter("providerId")==null? "":request.getParameter("providerId") %>">
					</TD> -->
                <TD class="bg_column" align=center>供应商名称</TD>
                <TD align=left class="bg_row_odd"><input
                    type="text" name="providerName"
                    value="<%=request.getParameter("providerName")==null? "":request.getParameter("providerName") %>">
                </TD>
                <TD class="bg_column" align=center>国家</TD>
                <TD align=left class="bg_row_odd"><select
                    name="countryCode">
                    <%
                        if (tGSCountry != null && tGSCountry.size() > 0) {
                            for (int i = 0; i < tGSCountry.size(); i++) {
                                GSCountryBean tGSCountryBean = (GSCountryBean) tGSCountry.get(i);
                    %>
                    <option
                        value="<%=tGSCountryBean.getGs_en_country_name()%>"><%=tGSCountryBean.getGs_country_name()%></option>
                    <%
                        }
                        } else {
                    %>
                    <option value="00">------无------</option>
                    <%
                        }
                    %>
                </select></TD>
            </TR>
            <TR height=20>
                <TD class="bg_column" align=center>省份</TD>
                <TD align=left class="bg_row_odd"><select
                    name="provinceCode"
                    onChange="changedistrict(this.value)">
                    <option value="00">---请选择省份---</option>
                    <%
                        String tProvCode = request.getParameter("provinceCode");
                        if (tGSProvince != null && tGSProvince.size() > 0) {
                            for (int i = 0; i < tGSProvince.size(); i++) {
                                GSProvinceBean tGSProvinceBean = (GSProvinceBean) tGSProvince.get(i);
                                if (tProvCode != null && tProvCode.equals(tGSProvinceBean.getGs_province_code())) {
                    %>
                    <option
                        value="<%=tGSProvinceBean.getGs_province_code()%>"
                        selected><%=tGSProvinceBean.getGs_province_name()%></option>
                    <%
                        } else {
                    %>
                    <option
                        value="<%=tGSProvinceBean.getGs_province_code()%>"><%=tGSProvinceBean.getGs_province_name()%></option>

                    <%
                        }
                            }
                        }
                    %>

                </select></TD>
                <TD class="bg_column" align=center>城市</TD>
                <TD align=left class="bg_row_odd"><select
                    name="districtCode" id="list3">
                    <%
                        String tDistrCode = request.getParameter("districtCode");
                        if (tProvCode != null) {
                            if (!tProvCode.equals("00")) {
                                String[][] temp = (String[][]) tMap2.get(tProvCode);
                                if (temp != null && temp.length > 0) {
                                    for (int i = 0; i < temp.length; i++) {
                                        if (tDistrCode != null && tDistrCode.equals(temp[i][0])) {
                    %>
                    <option value="<%=temp[i][0]%>" selected><%=temp[i][1]%></option>
                    <%
                        } else if (temp[i][0] != null) {
                    %>
                    <option value="<%=temp[i][0]%>"><%=temp[i][1]%></option>
                    <%
                        }
                                    }
                                }
                            } else {
                    %>
                    <option value="0000">---请选择城市---</option>
                    <%
                        }
                        } else {
                    %>
                    <option value="0000">---请选择城市---</option>
                    <%
                        }
                    %>

                </select></TD>
            </TR>
            <TR height=20>
                <TD class="bg_column" align=center>联系人</TD>
                <TD align=left class="bg_row_odd"><input
                    type="text" name="contactid"
                    value="<%=request.getParameter("contactid")==null? "":request.getParameter("contactid") %>">
                </TD>
                <TD class="bg_column" align=center>联系电话</TD>
                <TD align=left class="bg_row_odd"><input
                    type="text" name="contactphone"
                    value="<%=request.getParameter("contactphone")==null? "":request.getParameter("contactphone") %>">
                </TD>
            </TR>
            <% if(flag){
                 String status = request.getParameter("status")==null? "":request.getParameter("status");
               System.out.println(status);
            %>
             <tr>
                <TD class="bg_column" align=center>是否有效</TD>
                <TD align=left class="bg_row_odd"><select
                    name="status" >
                    <%  if(status.equals("1")){ %>
                    <option value="1">--有效--</option>
                    <option value="2">--全部--</option>
                    <option value="0">--无效--</option>
                    <%}else if(status.equals("0")) {%>
                    <option value="0">--无效--</option>
                    <option value="2">--全部--</option>
                    <option value="1">--有效--</option>
                    <%}else {%>
                    <option value="2">--全部--</option>
                    <option value="1">--有效--</option>
                    <option value="0">--无效--</option>
                    <%} %>
                </select></td>
                <td  class="bg_column" align=center>是否审核类</td>
                 <td  class="bg_row_odd" ><%= SelectManager.viewYesOrNoSelect("isAudit", (String)request.getParameter("isAudit"), true, "", "--全部--", "", "") %></td>
            </tr>
            <% }%>
        </table>
        </td>
    </tr>
</table>
<%
    if (tGSProvider != null) {
        int totalRecords = 0;
        int defaultPageSize = 10;
        totalRecords = tGSProvider.getRecordsSize();
%> <page:pager total='<%=totalRecords%>'
    defaultPageSize='<%=defaultPageSize%>'>
    <%
        tList = tGSProvider.getDisplayRecords(index.intValue(), pageSize.intValue());
    %>
</page:pager> <%
     }
 %>
</form>
<p align="center"><input type="button" class="kuang" value="查询"
    onclick="process('Q')" />&nbsp; <input type="button" class="kuang"
    value="清空" onclick="clean()" />&nbsp;</p>
<%
    if (tGSProvider != null) {
        ArrayList list = tList;
%>
<center>

<table width="100%" border="0" cellspacing="0" cellpadding="0"
    align="center">
    <tr>
        <td>
        <form name='pager' method="post">
        
        <input type=hidden name=ProviderId>
         <% if(flag){%>
             <input type=hidden
            name=providerName> <input type=hidden
            name=countryCode> <input type=hidden
            name=provinceCode> <input type=hidden
            name=districtCode> <input type=hidden name=contactid>
        <input type=hidden name=contactphone> <input type=hidden
            name=is_status>
           <%} %>
        <table class=bg_table id=tableId cellspacing=1 cellpadding=2
            width=98% align=center border=0>
            <tbody>

                <tr class="bg_column" height=20>
                <% if(flag){%>
          
                    <td  class="txt_content" width="60" valign="center " align="center" >
                       <input type="checkbox" name="sel_manufacture" onClick="allCheckBox()">
                    </td>       
                  <% }else{%>
                    <td class=top align=center width="5%"></td>
                  <%} %>
                    <td class=top align=center width="5%"></td>
                    <td class=top align=center>
                    <div align="center" class="txt_content">供应商编号</div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content">供应商名称</div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content">负责人</div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content">负责人电话</div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content">公司性质</div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content">经营范围</div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content">联系电话</div>
                    </td>
                     <% if(flag){%>
                    <td class=top align=center>
                    <div align="center" class="txt_content">是否有效</div>
                    </td>
                    <%} %>
                    <td class=top align=center>
                    <div align="center" class="txt_content">详细信息</div>
                    </td>
                </tr>
                <%
                    if (tList != null && tList.size() > 0) {
                            for (int i = 0; i < tList.size(); i++) {
                                GSProviderBean tStr = (GSProviderBean) tList.get(i);
                                String tTempStr = "";
                                if (i % 2 == 0) {
                                    tTempStr = "class=\"bg_row_odd\"";
                                } else {
                                    tTempStr = "class=\"bg_row_even\"";
                                }
                %>


                <tr <%=tTempStr%> height=20>
                     <% if(flag){%>
                    <td align="center"><input type=checkbox
                        id='ckbox' name="temporary_manufacture"
                        value="<%=tStr.getGs_provider_id()%>" onclick="">
                    </td>
                    <%} %>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><a
                        href="A400106.do?ProviderId=<%=tStr.getGs_provider_id()%>"
                        target="_blank"></a> <input type="button"
                        class="kuang" value="修改"
                        onclick="mod('<%=tStr.getGs_provider_id()%>')" />
                    </div>
                    </td>
                     <% if(!flag){%>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><input
                        type="button" class="kuang" value="删除"
                        onclick="del('<%=tStr.getGs_provider_id()%>')" />
                    </div>
                    </td>
                      <%} %>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><%=tStr.getGs_provider_id()%>
                    </div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><%=tStr.getGs_provider_name()%>
                    </div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><%=tStr.getGs_principal_id()%>
                    </div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><%=tStr.getGs_principal_phone()%>
                    </div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><%=tStr.getGs_corp_property()%>
                    </div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><%=tStr.getGs_work_scope()%>
                    </div>
                    </td>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><%=tStr.getGs_contact_phone()%>
                    </div>
                    </td>
                     <% if(flag){%>
                    <td class=top align=center>
                    <div align="center" class="txt_content">
                    <%
                        if (tStr.getGs_validity().equals("1")) {
                    %>
                    有效 <%
                        } else {
                    %> 无效 <%
                        }
                    %>
                    </div>
                    </td>
                    <%} %>
                    <td class=top align=center>
                    <div align="center" class="txt_content"><a
                        href="<%= response.encodeURL(request.getContextPath() + "/A400108.do") %>?providerId=<%=tStr.getGs_provider_id()%>"
                        target="blank">详细</a></div>
                    </td>
                </tr>

                <%
                    }
                %>
                <tr class="bg_column" height=20>
                    <td width="960" height="16" colspan="11"
                        align="right"><!--导航条--> <page:navigator
                        type='text' queryForm="providerviewform" /></td>

                    <%
                        } else {
                    %>
                    <font color="red">没有符合条件的供应商</font>
                    <%
                        }
                    %>
                
            </tbody>
        </table>
        </form>
        </td>
    </tr>
</table>
</center>
 <% if(!flag){%>
<form action="" name="delform" method="post"><input type=hidden
    name=ProviderId> <input type=hidden name=providerName>
<input type=hidden name=countryCode> <input type=hidden
    name=provinceCode> <input type=hidden name=districtCode>
<input type=hidden name=contactid> <input type=hidden
    name=contactphone></form>
<%} %>
<p align="center"><input type="button" class="kuang" value="增加"
    onclick="add()" />&nbsp; 
     <% if(flag){%>
    <input type="button" class="kuang"
    value="有效" onclick="setOK()" />&nbsp; <input type="button"
    class="kuang" value="无效" onclick="setNot()" />&nbsp;
    <%} %>
    <input type="button" class="kuang" value="导出"
    onclick="exportProvider()" />&nbsp; 
   <!--  
	<input type="button" class="kuang" width="58" height="24" value="供应商分类重置" onclick="providerImport();"/>
	-->
    </p>
    
<%
    }
%>
</body>
</html>
<%@ include file="../../framework/foot.jsp"%>